package ftl.fboriginal;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.facebook.android.AsyncFacebookRunner;
import com.facebook.android.Facebook;
import ftl.fboriginal.ImageDownloader;





public class FboriginalActivity extends Activity {
	
    private LoginButton btnLoginFB;
    private TextView txtEstado;
    private Button btnUploadFoto;
    private ImageView ivFoto;
    
    
    private AsyncFacebookRunner mAsyncRunner;
	private Facebook mFacebook;
    private ImageDownloader mImageDownloader;
	
	
    private String[] fbPermisos = new String[]{ "offline_access", "read_stream", "publish_stream","manage_pages","user_photos" };

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        btnLoginFB = (LoginButton) findViewById(R.id.login);
        txtEstado = (TextView) findViewById(R.id.txtEstado);
        ivFoto = (ImageView) findViewById(R.id.ivFoto);
        
        mFacebook = new Facebook("132599393489054");
        
        //Recupero el estado de FB del dispositivo.
        SessionStore.restore(mFacebook, this);
        SessionEvents.addAuthListener(new FacebookAuthListener());
        SessionEvents.addLogoutListener(new FacebookLogoutListener());
        btnLoginFB.init(this, mFacebook, fbPermisos);
        
        mImageDownloader = new ImageDownloader();
        mImageDownloader.download("http://www.neurocirugia.com/wp-content/themes/suffusion/images/follow/Facebook-01.png", ivFoto);
        
        
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        mFacebook.authorizeCallback(requestCode, resultCode, data);
    }
  
    
}